@extends('layouts.admin_iframe')
@section('content')
		<table class="table table-hover">
			<tr class="active">
			  <th width="30">cid</th>
			  <th>分类名称</th>

				<th>排序</th>
	
			  <th width="210">操作</th>
			</tr>
			@foreach($cate_datas_tree as $cdt)
			<tr>
				<td>{{$cdt->cid}}</td>
				<td>{{$cdt->_cname}}</td>
				<td><input onchange="order_change(this,{{$cdt->cid}})" type="text" name="sort" style="width:50px;" value="{{$cdt->sort}}"></td>
				<td>
					<a href="{{url('admin/cate/create_son/'.$cdt->cid.'/'.$cdt->type_tid)}}" class="btn btn-sm btn-primary">添加子类</a>
					<a href="{{url('admin/category/'.$cdt->cid.'/edit?tid='.$cdt->type_tid)}}" class="btn btn-sm btn-warning">编辑</a>
					<a href="javascript:;" onclick="cate_del({{$cdt->cid}})" class="btn btn-sm btn-danger">删除</a>
				</td>
			</tr>
				@endforeach
		</table>
		<script>
			function cate_del(cid){
				layer.confirm('您确定要删除此分类吗？', {
					btn: ['确定','取消'] //按钮
				}, function(){
					$.post("{{url('admin/category/')}}/" + cid, {'_token': '{{csrf_token()}}','_method': 'delete'}, function(db){
						if (db.status == 1) {
							window.location.reload();
							layer.msg(db.msg, {icon: 6});
						} else {
							layer.msg(db.msg, {icon: 5});
						}
					});
				}, function(){

				});
			}


		</script>
		<script>
			function order_change(obj,cate_id){
				var cate_order = $(obj).val();
				$.post("{{url('admin/cate/order_change')}}",{'_token':'{{csrf_token()}}','cid':cate_id,'sort':cate_order},function(data){
	//				alert(data.msg);
					if(data.status==1){
						layer.msg(data.msg, {icon: 6});
					}else{
						layer.msg(data.msg, {icon: 5});
					}
				});
			}
		</script>

@endsection
